package com.ruoyi.fly.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.fly.domain.ChlCoupons;
import com.ruoyi.fly.domain.vo.ChlCouponsSearchVo;
import com.ruoyi.fly.domain.vo.ChlCouponsVo;
import com.ruoyi.fly.domain.vo.DeleteVo;
import com.ruoyi.fly.mapper.ChlCouponsMapper;
import com.ruoyi.fly.service.ChlCouponsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: wdf
 * @Date: 2024/6/7
 */
@Service
public class ChlCouponsImpl implements ChlCouponsService {

    @Autowired
    private ChlCouponsMapper chlCouponsMapper;

    @Override
    public ChlCouponsService selectChlCouponsById(String id) {
        return null;
    }

    /**
     * 查询消费金列表
     * @param chlCouponsSearchVo 车龙惠优惠金
     * @return
     */
    @Override
    public R selectChlCouponsList(ChlCouponsSearchVo chlCouponsSearchVo) {
        PageHelper.startPage(chlCouponsSearchVo.getPageNum(), chlCouponsSearchVo.getPageSize());
        List<ChlCoupons> chlCoupons = chlCouponsMapper.selectChlCouponsList(chlCouponsSearchVo);
        PageInfo<ChlCoupons> pageInfo = new PageInfo<>(chlCoupons);
        return R.ok(pageInfo);
    }

    /**
     * 添加消费金
     * @param chlCoupons 车龙惠优惠金
     * @return
     */
    @Override
    public R  insertChlCoupons(ChlCouponsVo chlCoupons) {
        chlCoupons.setCreateUser(String.valueOf(SecurityUtils.getUserId()));
        return chlCouponsMapper.insertChlCoupons(chlCoupons)>0?R.ok("添加成功"):R.fail("添加失败");
    }

    /**
     * 修改消费金
     * @param chlCoupons 车龙惠优惠金
     * @return
     */
    @Override
    public R updateChlCoupons(ChlCouponsVo chlCoupons) {
        chlCoupons.setUpdateUser(String.valueOf(SecurityUtils.getUserId()));
        return chlCouponsMapper.updateChlCoupons(chlCoupons)>0?R.ok("修改成功"):R.fail("修改失败");
    }

    /**
     * 删除车龙惠优惠金信息
     * @param ids 需要删除的车龙惠优惠金主键集合
     * @return
     */
    @Override
    public R deleteChlCouponsByIds(String[] ids) {
        return chlCouponsMapper.deleteChlCouponsByIds(ids)>0?R.ok("删除成功"):R.fail("删除失败");
    }

    @Override
    public R deleteChlCouponsById(String id) {
        return chlCouponsMapper.deleteChlCouponsById(id)>0?R.ok("删除成功"):R.fail("删除失败");
    }
}
